import type { TableColumn } from '@/components/core/dynamic-table';

export type TableListItem = API.UserListPageResultItem;
export type TableColumnItem = TableColumn<TableListItem>;

const operationParams = [
  {
    label: '全部状态',
    value: '',
  },
  {
    label: '待采购',
    value: 1,
  },
  {
    label: '采购完成',
    value: 2,
  },
];

export const baseColumns: TableColumn[] = [
  {
    title: '关键字',
    align: 'left',
    dataIndex: 'keyword',
    hideInTable: true,
    formItemProps: {
      labelWidth: 55,
      componentProps: () => {
        return {
          placeholder: '可输入采购编号、名称、申请人搜索',
          disabledLabelWidth: true,
        };
      },
    },
  },

  {
    title: '采购编号',
    align: 'left',
    dataIndex: 'userNum',
    hideInSearch: true,
  },
  {
    title: '采购名称',
    align: 'left',
    dataIndex: 'userLogin',
    hideInSearch: true,
  },

  {
    title: '状态',
    align: 'left',
    dataIndex: 'type',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: operationParams,
        defaultValue: '',
      },
    },
    customRender: ({ record }) =>
      operationParams.filter((item) => item.value == record.type)[0].label,
  },
  {
    title: '申请时间',
    dataIndex: 'time',
    hideInTable: true,
    formItemProps: {
      component: 'RangePicker',
      componentProps: () => {
        return {
          format: 'YYYY/MM/DD',
          valueFormat: 'YYYY/MM/DD',
        };
      },
    },
  },
  {
    title: '申请人',
    align: 'left',
    dataIndex: 'userName',
    hideInSearch: true,
  },
  {
    title: '申请时间',
    align: 'left',
    dataIndex: 'action',
    hideInSearch: true,
  },
  {
    title: '关联项目编号',
    align: 'left',
    dataIndex: 'operationTime',
    hideInSearch: true,
  },
  {
    title: '关联项目名称',
    align: 'left',
    dataIndex: 'operationName',
    hideInSearch: true,
  },
];
